package com.itheima.askme.controller;


import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;
import java.util.UUID;

@RestController
@RequestMapping("verifyCodes")
@Slf4j
public class CodeController {


    @GetMapping("/regist")
    public  String regist(HttpSession session){

        String code = UUID.randomUUID().toString().replaceAll("-","").substring(0, 4);
         session.setAttribute("regist_code",code);
         log.info("===regist_code==="+code);
        return  code;
    }

    @GetMapping("/login")
    public  String login(HttpSession session){

        String code = UUID.randomUUID().toString().replaceAll("-","").substring(0, 4);
        session.setAttribute("login_code",code);
        log.info("===login_code==="+code);
        return  code;
    }



}
